//
//  CarStyleCell.m
//  Zhiche-Carriage
//
//  Created by LeeBruce on 16/6/14.
//  Copyright © 2016年 LeeBruce. All rights reserved.
//

#import "CarStyleCell.h"
#import <Masonry.h>

@implementation CarStyleCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self initSubViews];
    }
    
    return self;
}

-(void)initSubViews
{
    __weak typeof(self) weakSelf = self;
    
    self.ImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.ImageView];
    [self.ImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(18);
        make.centerY.equalTo(weakSelf);
        make.size.mas_equalTo(CGSizeMake(33 *kHeight, 33 * kHeight));
        
        
    }];

    self.ImageView.contentMode = UIViewContentModeScaleAspectFit;
    
    UILabel *label = [[UILabel alloc]init];
    [self.contentView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(weakSelf.ImageView.mas_right).offset(20);
        make.top.mas_equalTo(10 * kHeight);
        
        make.size.mas_equalTo(CGSizeMake(65 * kWidth, 20 * kHeight));
        
    }];
    label.text = @"品牌/车型:";
    label.textColor = littleBlackColor;
    label.font = Font(13);
    
    
    self.nameLabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(label.mas_right).with.offset(10);
        make.top.mas_offset(10 * kHeight);
        make.size.mas_offset(CGSizeMake(200, 20 * kHeight));
        
    }];
    self.nameLabel.textColor = littleBlackColor;
    
    self.nameLabel.font = Font(13);
    
//    self.nameLabel.text = @"奔驰－E200系列";
    
    
    
    
    UILabel *label1 = [[UILabel alloc]init];
    [self.contentView addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.ImageView.mas_right).offset(20);
        make.top.mas_equalTo(label.mas_bottom).offset(0);
        
        make.size.mas_equalTo(CGSizeMake(30 * kWidth , 25 * kHeight));
        
    }];
    label1.text = @"VIN:";
    label1.textColor = littleBlackColor;
    label1.font = Font(13);
    
    self.numberLabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.numberLabel];
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(weakSelf.nameLabel);
        make.centerY.equalTo(label1);
        make.size.mas_offset(CGSizeMake(300, 20 * kHeight));
    }];
    
    self.numberLabel.text = @"dfafasfasfasdfasdf";
    self.numberLabel.font = Font(13);
//    self.numberLabel.textAlignment = NSTextAlignmentRight;
    self.numberLabel.textColor = littleBlackColor;

    
   
}


-(void)setNumber:(NSInteger)number
{

//    [self initCellSubviewsWithInteger:number];

}

+(CGFloat)cellHeightWithInteger:(NSInteger)integer
{
    CGFloat height = 0;
//    height = integer * cellHeight;
    return height;
    
}

//+(CGFloat)calsLabelHeightWithModel:(CarStyleModel *)model
//{
//    CarStyleCell *cell = [[CarStyleCell alloc]init];
//    
//    [cell initCellSubviewsWithInteger:model.integet];
//    
//    
//    CGFloat height = 0;
//    height = model.integet * cellHeight;
//    return height;
//}

-(void)initCellSubviewsWithInteger:(NSInteger)integer
{
    __weak typeof(self) weakSelf = self;

    //下面VIN
    for (int i = 0; i < integer; i++) {
        
        
        UILabel *lineL = [[UILabel alloc]init];
        [self.contentView addSubview:lineL];
        [lineL mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(weakSelf.nameLabel);
            make.top.equalTo(weakSelf.nameLabel.mas_bottom).offset(0 + cellHeight*i);
            make.size.mas_equalTo(CGSizeMake(screenWidth - 44, 0.5));
            
        }];
        lineL.backgroundColor = littleBlackColor;
        
        
        UILabel *label = [[UILabel alloc]init];
        [self.contentView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(weakSelf.nameLabel);
            make.top.equalTo(weakSelf.nameLabel.mas_bottom).offset(0 + cellHeight * i);
            make.size.mas_equalTo(CGSizeMake(screenWidth/2.0 + 50, cellHeight));
            
        }];
        
        //
        label.font = Font(15);
        label.text = [NSString stringWithFormat:@"%d.VIN 123124234123123123",(i + 1)];
        
        
        
        
        UILabel *label1 = [[UILabel alloc]init];
        [self.contentView addSubview:label1];
        [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(label.mas_right).offset(0);
            make.top.equalTo(weakSelf.nameLabel.mas_bottom).offset(0 + cellHeight * i);
            make.size.mas_equalTo(CGSizeMake(50, cellHeight));
            
        }];
        //
        label1.font = Font(15);
        label1.text = [NSString stringWithFormat:@"已提车"];
        
        
    }
    

  
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
